package com.dq.eduservice.controller;

import com.dq.commonutils.vo.Result;
import com.dq.eduservice.service.EduVideoService;
import com.dq.eduservice.vo.chapter.VideoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 小节
 * $tableInfo.name-API
 * @author Dq
 * @since 2022-07-22 19:51:20
 */
@RestController
@RequestMapping("eduservice/video")
public class EduVideoController {

    @Autowired
    private EduVideoService videoService;

    /**
     * 根据章节id获取章节部分信息
     * @param videoId
     * @return
     */
    @GetMapping("getVideo/{videoId}")
    public Result getVideoById(@PathVariable String videoId){
         VideoVo videoVo = videoService.getVideoById(videoId);
        return Result.success(videoVo);
    }

    /**
     * 添加小节
     * @param videoVo
     * @return
     */
    @PostMapping("addVideo")
    public Result addVideo(@RequestBody VideoVo videoVo){
        videoService.addVideo(videoVo);
        return Result.success(null);
    }


    /**
     * 修改小节
     * @param videoVo
     * @return
     */
    @PostMapping("updateVideo")
    public Result updateVideo(@RequestBody VideoVo videoVo){
        videoService.updateVideo(videoVo);
        return Result.success(null);
    }

    /**
     * 删除小节
     * @param videoId
     * @return
     */
    @PostMapping("{videoId}")
    public Result deleteVideoById(@PathVariable String videoId){
        videoService.deleteVideoById(videoId);
        return Result.success(null);
    }
}